package com.api.syh56.shengyunhui.controller.admin;

import com.api.syh56.shengyunhui.common.CommonResult;
import com.api.syh56.shengyunhui.entity.Driver;
import com.api.syh56.shengyunhui.entity.dto.DriverDTO;
import com.api.syh56.shengyunhui.entity.vo.DriverVO;
import com.api.syh56.shengyunhui.service.AdminDriverService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * 司机管理
 */
@RestController
@RequestMapping("admin/driver")
public class AdminDriverController {
    @Autowired
    private AdminDriverService adminDriverService;


    /**
     * 添加司机
     * @param driverDTO
     * @return
     */
    @PostMapping("insert")
    public CommonResult<Object> insert(@RequestBody DriverDTO driverDTO){
        adminDriverService.insert(driverDTO);
        return CommonResult.success(null);
    }

    /**
     * 专线指派司机
     * @param delID
     * @param driID
     * @return
     */
    @PostMapping("assign")
    public CommonResult<Object> assign(@RequestBody Long delID,
                                       @RequestBody Long driID){
        adminDriverService.assign(delID,delID);
        return CommonResult.success(null);
    }

    /**
     * 查看司机
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("select")
    public CommonResult<Object> select(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                       @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){
        Page<DriverVO> driverVO = adminDriverService.select(pageNum,pageSize);
        return CommonResult.success(driverVO);
    }
}
